﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using BLL;
using System.IO;
namespace Stationery.UC
{
    public partial class UC_Handscript : System.Web.UI.UserControl
    {
        BLL_MenuURL bll_MenuURL = new BLL_MenuURL();
        MenuURL menu_URL = new MenuURL();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ASPxComboBoxHandscript_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string strType = ASPxComboBoxHandscript.Value.ToString();
                ASPxHtmlEditorHandScript.Html = "";
                switch (strType)
                {
                    case Utils.menu_intro:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_intro)))[0];
                        break;
                    case Utils.menu_contact:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_contact)))[0];
                        break;
                    case Utils.menu_place:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_place)))[0];
                        break;
                    case Utils.menu_service:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_service)))[0];
                        break;
                    case Utils.menu_guide:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_guide)))[0];
                        break;
                    case Utils.menu_process:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_process)))[0];
                        break;
                    default:
                        break;
                }

                ASPxHtmlEditorHandScript.Html =menu_URL.DESCRIPTION;
            }
        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string strType = ASPxComboBoxHandscript.Value.ToString();
                switch (strType)
                {
                    case Utils.menu_intro:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_intro)))[0];
                        break;
                    case Utils.menu_contact:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_contact)))[0];
                        break;
                    case Utils.menu_place:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_place)))[0];
                        break;
                    case Utils.menu_service:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_service)))[0];
                        break;
                    case Utils.menu_guide:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_guide)))[0];
                        break;
                    case Utils.menu_process:
                        menu_URL = bll_MenuURL.Lst_MenuURL(bll_MenuURL.Get_MenuURL_Dynamic(String.Format("CODE = '{0}'", Utils.menu_process)))[0];
                        break;
                    default:
                        break;
                }
                menu_URL.DESCRIPTION = ASPxHtmlEditorHandScript.Html;
                bll_MenuURL.InsertUpdate_MenuURL(menu_URL);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Thành công');", true);
            }
        }
    }
}